Skip to content

Add install rules and system-sodium option for packaging#153

Merged
gafferongames merged 1 commit into
mainfrom
homebrew-support
Jul 9, 2026
Merged

Add install rules and system-sodium option for packaging#153
gafferongames merged 1 commit into
mainfrom
homebrew-support

Conversation

@gafferongames

Copy link
Copy Markdown
Contributor

Summary

Groundwork for distributing netcode through package managers (homebrew, apt, vcpkg, …). No change to the default developer build — still static, still vendored sodium, still cmake -B build && cmake --build build.

  • project() carries a version (1.3.1); libnetcode gets VERSION/SOVERSION for shared-library symlinks.
  • -DNETCODE_SYSTEM_SODIUM=ON links the system libsodium (find_library) instead of the vendored copy — interchangeable, since the vendored subset is a byte-identical slice of upstream. Package managers want this so their libsodium owns the crypto and its security updates.
  • -DBUILD_SHARED_LIBS=ON now works; vendored sodium objects are built PIC so they fold into a shared libnetcode.
  • cmake --install installs netcode.h + the library via GNUInstallDirs (NETCODE_INSTALL=OFF to disable when embedding).
  • CI: new ubuntu system-sodium leg builds shared against libsodium-dev, tests, installs, and asserts the install layout.

Verification (local, macOS Apple Silicon)

  • Default build (vendored, static): full suite passes.
  • System sodium against homebrew libsodium 1.0.22, static and shared: full suite passes; otool -L confirms it links the homebrew dylib.
  • Staged cmake --install: produces include/netcode.h + lib/libnetcode.{1.3.1.dylib,1.dylib,dylib}.
  • A standalone consumer program (create server + client, parse address, use the new create-error API) compiled against only the installed header and shared lib, and ran clean.

Homebrew — next step (needs maintainer)

This PR is the prerequisite. Once merged and a v1.3.1 tag is cut, the formula can be submitted to homebrew-core (netcode easily clears notability: 2.5k★). A ready-to-fill formula is drafted and attached in the PR discussion — it only needs the release tarball's sha256. Submitting to homebrew-core is a PR to Homebrew/homebrew-core from an account, which I can't do autonomously — see the checklist below.

🤖 Generated with Claude Code

Enables distribution via package managers such as homebrew. No change to
the default developer build (static, vendored sodium).

- project() now carries a version (1.3.1); libnetcode gets VERSION /
  SOVERSION for proper shared-library symlinks.
- NETCODE_SYSTEM_SODIUM=ON links the system libsodium via find_library
  instead of the vendored copy (the two are interchangeable — the
  vendored subset is a byte-identical slice of upstream). Package
  managers prefer this so their libsodium supplies the crypto and gets
  security updates.
- BUILD_SHARED_LIBS is now honored; vendored sodium objects are built
  position-independent so they fold into a shared libnetcode.
- NETCODE_INSTALL (default ON) generates an install target for netcode.h
  and the library, using GNUInstallDirs.
- CI: new ubuntu system-sodium leg builds shared against libsodium-dev,
  runs the tests, installs, and checks the layout.
- BUILDING.md / CLAUDE.md document the packaging options.

Verified locally: default, system-sodium (static + shared) against
homebrew libsodium 1.0.22, staged install, and a standalone consumer
program compiled against only the installed header + shared library.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gafferongames gafferongames merged commit 294cf8e into main Jul 9, 2026
12 checks passed
@gafferongames gafferongames deleted the homebrew-support branch July 9, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant